package cate.game.admin.menu.pvp;

import cate.game.GameBody;
import cate.game.admin.menu.MenuSetup;
import cate.game.pvp.ladder.msg.*;
import cp.solution.util.collection.ListKit;
import easy.java.practice.errorcode.EcException;

public class LadderMenu extends MenuSetup {

    public LadderMenu(GameBody game) {
        super("天梯赛");

        reg(game, "个人数据请求", 0, "无参数", (role, params) -> {
            LadderDataReq req = new LadderDataReq();
            req.action(game, role);
        });

        reg(game, "刷新请求", 0, "无参数", (role, params) -> {
            LadderRefreshReq req = new LadderRefreshReq();
            req.action(game, role);
        });

        reg(game, "挑战请求", 0, "无参数", (role, params) -> {
            if(ListKit.isEmpty(role.getPvp().ladder.opponents)) {
                throw new EcException("请先刷新对手");
            }
            LadderChallengeReq req = new LadderChallengeReq();
            req.opponentId = role.getPvp().ladder.opponents.get(0).id;
            req.action(game, role);
        });

        reg(game, "扫荡请求", 0, "无参数", (role, params) -> {
            if(ListKit.isEmpty(role.getPvp().ladder.opponents)) {
                throw new EcException("请先刷新对手");
            }
            LadderMopReq req = new LadderMopReq();
            req.action(game, role);
        });

        reg(game, "战报请求", 1, "1: 玩家录像 2: 大神风采", (role, params) -> {
            LadderReplayReq req = new LadderReplayReq();
            req.type = Byte.parseByte(params.get(0));
            req.action(game, role);
        });


        reg(game, "詳情请求", 1, "id", (role, params) -> {
            LadderOppoDetailReq req = new LadderOppoDetailReq();
            req.opponentId = params.get(0);
            req.robot = true;
            req.action(game, role);
        });
    }
}
